<html>
<head>
  <meta charset="utf-8">
  <title>Blockly Code</title>
  <script type="text/javascript" src="../../blockly_compressed.js"></script>
  <script type="text/javascript" src="../../generators/javascript.js"></script>
  <script type="text/javascript" src="../../generators/javascript/control.js"></script>
  <script type="text/javascript" src="../../generators/javascript/logic.js"></script>
  <script type="text/javascript" src="../../generators/javascript/math.js"></script>
  <script type="text/javascript" src="../../generators/javascript/text.js"></script>
  <script type="text/javascript" src="../../generators/javascript/lists.js"></script>
  <script type="text/javascript" src="../../generators/javascript/colour.js"></script>
  <script type="text/javascript" src="../../generators/javascript/variables.js"></script>
  <script type="text/javascript" src="../../generators/javascript/procedures.js"></script>
  <script type="text/javascript" src="../../generators/python.js"></script>
  <script type="text/javascript" src="../../generators/python/control.js"></script>
  <script type="text/javascript" src="../../generators/python/logic.js"></script>
  <script type="text/javascript" src="../../generators/python/math.js"></script>
  <script type="text/javascript" src="../../generators/python/text.js"></script>
  <script type="text/javascript" src="../../generators/python/lists.js"></script>
  <script type="text/javascript" src="../../generators/python/colour.js"></script>
  <script type="text/javascript" src="../../generators/python/variables.js"></script>
  <script type="text/javascript" src="../../generators/python/procedures.js"></script>
  <style>
    html, body {
      background-color: #fff;
      margin: 0;
      padding: 0;
      overflow: hidden;
    }
    .blocklySvg {
      height: 100%;
      width: 100%;
    }
  </style>
  <script>
    (function() {
      // Load the language-specific files listed on the URL.
      var files =
          decodeURIComponent(window.location.search.substring(1)).split('&');
      for (var x = 0; x < files.length; x++) {
        var file = files[x];
        if (file.match(/^\w+\/\w+\.js$/)) {
          document.writeln('<script type="text/javascript" ' +
              'src="../../language/' + file + '"><' + '/script>');
        } else {
          console.error('Illegal language file: ' + file);
        }
      }
    })();

    function init() {
      var rtl = false;
      var toolbox = null;
      if (window.parent.document) {
        // document.dir fails in Mozilla, use document.body.parentNode.dir.
        // https://bugzilla.mozilla.org/show_bug.cgi?id=151407
        rtl = window.parent.document.body.parentNode.dir == 'rtl';
        toolbox = window.parent.document.getElementById('toolbox');
      }
      Blockly.inject(document.body,
          {path: '../../',
           rtl: rtl,
           toolbox: toolbox});

      if (window.parent.init) {
        // Let the top-level application know that Blockly is ready.
        window.parent.init(Blockly);
      } else {
        // Attempt to diagnose the problem.
        var msg = 'Error: Unable to communicate between frames.\n\n';
        if (window.parent == window) {
          msg += 'Try loading index.html instead of frame.html';
        } else if (window.location.protocol == 'file:') {
          msg += 'This may be due to a security restriction preventing\n' +
              'access when using the file:// protocol.\n' +
              'http://code.google.com/p/chromium/issues/detail?id=47416';
        }
        alert(msg);
      }
    }
  </script>
</head>
<body onload="init()">
</body>
</html>
